package com.ruoyi.secondvitim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.secondvitim.domain.VitimMessage;
import com.ruoyi.secondvitim.service.IVitimMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 互动平台消息Controller
 * 
 * @author alonso_ecit
 * @date 2025-11-17
 */
@RestController
@RequestMapping("/secondVitim/vitimMessage")
public class VitimMessageController extends BaseController
{
    @Autowired
    private IVitimMessageService vitimMessageService;

    /**
     * 查询互动平台消息列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(VitimMessage vitimMessage)
    {
        startPage();
        List<VitimMessage> list = vitimMessageService.selectVitimMessageList(vitimMessage);
        return getDataTable(list);
    }

    /**
     * 导出互动平台消息列表
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:export')")
    @Log(title = "互动平台消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VitimMessage vitimMessage)
    {
        List<VitimMessage> list = vitimMessageService.selectVitimMessageList(vitimMessage);
        ExcelUtil<VitimMessage> util = new ExcelUtil<VitimMessage>(VitimMessage.class);
        util.exportExcel(response, list, "互动平台消息数据");
    }

    /**
     * 获取互动平台消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vitimMessageService.selectVitimMessageById(id));
    }

    /**
     * 新增互动平台消息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:add')")
    @Log(title = "互动平台消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VitimMessage vitimMessage)
    {
        return toAjax(vitimMessageService.insertVitimMessage(vitimMessage));
    }

    /**
     * 修改互动平台消息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:edit')")
    @Log(title = "互动平台消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VitimMessage vitimMessage)
    {
        return toAjax(vitimMessageService.updateVitimMessage(vitimMessage));
    }

    /**
     * 删除互动平台消息
     */
    @PreAuthorize("@ss.hasPermi('secondVitim:vitimMessage:remove')")
    @Log(title = "互动平台消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vitimMessageService.deleteVitimMessageByIds(ids));
    }
}
